package com.robooot.business_counter.model;

import java.io.Serializable;
import java.util.HashMap;

public class ApiResult implements Serializable {

    private Integer result;
    private String message;
    private Object data;

    public static ApiResult ok() {
        return ok(new HashMap<>(), "处理成功");
    }

    public static ApiResult ok(Object data) {
        return ok(data, "处理成功");
    }

    public static ApiResult ok(Object data, String message) {
        ApiResult r = new ApiResult();
        r.result = 0;
        r.message = message;
        r.data = data;
        return r;
    }

    @Override
    public String toString() {
        return "ApiResult{" +
                "result=" + result +
                ", message='" + message + '\'' +
                ", data=" + data +
                '}';
    }

    public static ApiResult bad(Integer result, String message) {
        ApiResult r = new ApiResult();
        r.result = result;
        r.message = message;
        r.data = new HashMap<String, String>();
        return r;
    }

    public Integer getResult() {
        return result;
    }

    public void setResult(Integer result) {
        this.result = result;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
